﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BaseObj;
using System.Text;

public partial class Controls_UserNavigation : BaseControl
{
    private string target = "mainFrame";

    /// <summary>
    /// 导航打开窗口目标（如："_blank",默认值"mainframe"）
    /// </summary>
    public string Target
    {
        get{ return this.target;}
        set{ this.target = value;}

    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.FillNavigationText();
    }

    /// <summary>
    /// 输出用户拥有资源导航
    /// </summary>
    private void FillNavigationText()
    {
        if (this.user.Roles != null)
        {
            StringBuilder sb = new StringBuilder();
            
            for (int i = 0; i < this.user.Roles.Length; i++)
            {
                if (this.user.Roles[i].Resources != null)
                {
                    
                    for (int j = 0; j < this.user.Roles[i].Resources.Length; j++)
                    {
                        //输出导航信息：
                        sb.Append("<a href=\"");
                        sb.Append(this.user.Roles[i].Resources[j].ResourceUrl);
                        sb.Append("\" target=\"");
                        sb.Append(this.target);
                        sb.Append("\">");
                        sb.Append(this.user.Roles[i].Resources[j].ResourceName);
                        sb.Append("</a>");
                        sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;");
                    }
                }
            }
            this.ltrNavigation.Text = sb.ToString();
        }

    }
}
